package com.ming.controller;

import com.ming.po.DeliveryAddress;
import com.ming.po.ResponseBean;
import com.ming.service.DeliveryAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/DeliveryAddressController")
public class DeliveryAddressController {

	@Autowired
	private DeliveryAddressService das;

	@GetMapping("/listDeliveryAddressByUserId")
	public ResponseBean<List<DeliveryAddress>> listDeliveryAddressByUserId(String userId){
		return das.listDeliveryAddressByUserId(userId);
	}

	@PostMapping("/saveDeliveryAddress")
	public ResponseBean<Integer> saveDeliveryAddress(DeliveryAddress da){
		return das.saveDeliveryAddress(da);
	}

	@GetMapping("/getDeliveryAddressById")
	public ResponseBean<DeliveryAddress> getDeliveryAddressById(Integer daId){
		return das.getDeliveryAddressById(daId);
	}

	@PostMapping("/updateDeliveryAddress")
	public ResponseBean<Integer> updateDeliveryAddress(DeliveryAddress da){
		return das.updateDeliveryAddress(da);
	}

	@PostMapping("/removeDeliveryAddress")
	public Object removeDeliveryAddress(Integer daId){
		return das.removeDeliveryAddress(daId);
	}
}
